package com.kfm.jdbc.day0324;

import com.kfm.jdbc.day0324.model.User;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

public class TestDBUtils {

    public static void main(String[] args) {

        try {
            DBUtils<User> dbUtils = new DBUtils<>();
            //String sql = "update users set password = '123' where id = ?";
            //int i = dbUtils.executeUpdate(sql, 2);
            //if (i > 0) {
            //    System.out.println("执行成功");
            //}

            String sql = "select * from users where id = ?";
            List<User> users = dbUtils.executeQuery(sql, new User.UsersRecover(), 1);
            System.out.println(Arrays.toString(users.toArray()));
            //while (resultSet.next()) {
            //    System.out.println("id : " + resultSet.getObject("id"));
            //    System.out.println("name : " + resultSet.getObject("name"));
            //    System.out.println("password : " + resultSet.getObject("password"));
            //}
            dbUtils.close();

        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
